﻿namespace Example.Structural
{
    using Example.Structural.Bridge;

    using Xunit;

    /// <summary>
    /// Decouple an abstraction from its implementation so that the two can vary independently.
    /// </summary>
    public sealed class BridgeFacts
    {
        [Fact]
        public void fan_with_dimmer()
        {
            var power = new Dimmer();
            var lamp = new Fan(power);

            power.On(5);
            Assert.Equal(480, lamp.Rpm);

            power.On(10);
            Assert.Equal(960, lamp.Rpm);

            power.Off();
            Assert.Equal(0, lamp.Rpm);
        }

        [Fact]
        public void fan_with_switch()
        {
            var power = new Switch();
            var lamp = new Fan(power);

            power.On();
            Assert.Equal(960, lamp.Rpm);

            power.Off();
            Assert.Equal(0, lamp.Rpm);
        }

        [Fact]
        public void lamp_with_dimmer()
        {
            var power = new Dimmer();
            var lamp = new Lamp(power);

            power.On(5);
            Assert.Equal(180, lamp.Lumen);

            power.On(10);
            Assert.Equal(360, lamp.Lumen);

            power.Off();
            Assert.Equal(0, lamp.Lumen);
        }

        [Fact]
        public void lamp_with_switch()
        {
            var power = new Switch();
            var lamp = new Lamp(power);

            power.On();
            Assert.Equal(360, lamp.Lumen);

            power.Off();
            Assert.Equal(0, lamp.Lumen);
        }
    }
}